// Crow - A Fast and Easy to use microframework for the web
// This is a simplified version for demonstration purposes
// In production, use the full Crow library

#ifndef CROW_H
#define CROW_H

#include <string>
#include <map>
#include <vector>
#include <functional>
#include <sstream>
#include <iostream>

namespace crow {
    struct json {
        std::map<std::string, std::string> data;
        
        static json load(const std::string& str) {
            json j;
            // Simplified JSON parsing
            return j;
        }
        
        std::string s() const {
            return "";
        }
        
        int i() const {
            return 0;
        }
    };
    
    struct response {
        int code;
        std::string body;
        
        response(int c, const std::string& b) : code(c), body(b) {}
        response(const std::string& b) : code(200), body(b) {}
    };
    
    using handler = std::function<response(const std::string&)>;
    
    class SimpleApp {
    private:
        std::map<std::string, handler> routes;
        int port_num = 8080;
        bool multithreaded_flag = false;
        
    public:
        SimpleApp& port(int p) {
            port_num = p;
            return *this;
        }
        
        SimpleApp& multithreaded() {
            multithreaded_flag = true;
            return *this;
        }
        
        template<typename Func>
        void route(const std::string& path, Func&& handler) {
            routes[path] = handler;
        }
        
        void run() {
            std::cout << "Server running on port " << port_num << std::endl;
            std::cout << "Available routes:" << std::endl;
            for (const auto& [path, _] : routes) {
                std::cout << "  GET " << path << std::endl;
            }
            std::cout << "\nPress Ctrl+C to stop the server" << std::endl;
            
            // Simulate server running
            while (true) {
                // In real implementation, this would start the HTTP server
            }
        }
    };
    
    // HTTP method literals
    struct method {
        static const char* POST;
    };
    
    const char* method::POST = "POST";
    
    // Route registration helper
    template<typename Func>
    void CROW_ROUTE(SimpleApp& app, const std::string& path) {
        app.route(path, [](const std::string&) {
            return response("Route handler");
        });
    }
}

#endif
